package us.mooresr.geartrack.client.events;

import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.EventHandler;
import us.mooresr.geartrack.shared.model.ItemType;
import com.google.gwt.event.shared.HasHandlers;

public class ItemTypeCreatedEvent extends
		GwtEvent<ItemTypeCreatedEvent.ItemTypeCreatedHandler> {

	public static Type<ItemTypeCreatedHandler> TYPE = new Type<ItemTypeCreatedHandler>();
	private ItemType itemType;

	public interface ItemTypeCreatedHandler extends EventHandler {
		void onItemTypeCreated(ItemTypeCreatedEvent event);
	}

	public ItemTypeCreatedEvent(ItemType itemType) {
		this.itemType = itemType;
	}

	public ItemType getItemType() {
		return itemType;
	}

	@Override
	protected void dispatch(ItemTypeCreatedHandler handler) {
		handler.onItemTypeCreated(this);
	}

	@Override
	public Type<ItemTypeCreatedHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<ItemTypeCreatedHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, ItemType itemType) {
		source.fireEvent(new ItemTypeCreatedEvent(itemType));
	}
}
